package test;

import java.util.Random;

public class ThreadProducter implements Runnable {
	private ThreadStorage storage;
	private static int id = 0;
	private int currId = id++;
	
	public ThreadProducter(ThreadStorage storage){
		this.storage = storage;
		
	}
	
	@Override
	public void run() {
		while(true){
			Random random = new Random();
			Thread.currentThread().setName("Producter--" + currId);
			int id = random.nextInt(5000) + 5000;
			ThreadProduct product = new ThreadProduct(id, "paper" + id);
			storage.push(product);
			try {
				Thread.sleep(500);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
